package com.glory.dgcpcpda.adapter;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.activity.mfg.MaterielDownActivity;
import com.glory.dgcpcpda.activity.mfg.MaterielUpActivity;
import com.glory.dgcpcpda.activity.mfg.ToolUnBindActivity;
import com.glory.dgcpcpda.entity.ToolEntity;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_Utils;

import java.util.List;

/**
 * FileName: ReplacrToolListAdapter
 * Author: XJH
 * Date: 2020/9/3 17:13
 * Description:
 * History:
 */
public class ReplaceToolListAdapter extends BaseQuickAdapter<ToolEntity, BaseViewHolder> {
    private boolean isStart = true;
    private String mEqp = "";

    public ReplaceToolListAdapter(@Nullable List<ToolEntity> data) {
        super(R.layout.item_bin_info_list,data);
    }

    public void setStart(boolean b){
        this.isStart = b;
    }

    public void setEqp(String eqp){
        this.mEqp = eqp;
    }

    @Override
    protected void convert(BaseViewHolder helper, ToolEntity item) {
        String  toolType=item.getEAPPARAM()==null?"":item.getEAPPARAM();
        String toolName;
        if("Suction_Nozzle".equals(toolType)){
            toolName="吸嘴";
        }else if("Thimble".equals(toolType)){
            toolName="顶针";
        }else{
            toolName=toolType;
        }
        helper.setText(R.id.list_tv1,toolName);
        helper.setText(R.id.list_tv2,item.getTOOLID());
        helper.setText(R.id.list_tv3,"下机");

        helper.getView(R.id.list_tv3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!isStart){
                    Bundle bundle = new Bundle();
                    bundle.putString("EQPID",mEqp);
                    bundle.putString("TOOLID",item.getTOOLID());
                    FreeApi_Utils.skipWithExtraIntent("header",bundle,mContext, ToolUnBindActivity.class);
                }
            }
        });
    }
}
